import archiver from "archiver";
import { createWriteStream } from "fs";
import { resolve } from "path";

// let __dirname = dirname(fileURLToPath(import.meta.url))

// 项目根目录
const rootDir = process.cwd();

const compressFile = async () => {
  const output = createWriteStream(resolve(rootDir, "dist.zip"));

  const archive = archiver("zip", {
    zlib: { level: 9 },
  });

  archive.pipe(output);
  archive.directory("dist/", false);

  await archive.finalize();
};

export default compressFile;
